package org.lemon.transport.context.model;

import lombok.Data;
import org.server.transport.gen.SessionProto;
import org.server.transport.gen.TransportProto;
import org.lemon.transport.context.session.SessionMsgListener;

import java.util.concurrent.ScheduledFuture;

@Data
public class SessionMetaData {

    private volatile SessionProto.SessionInfoProto sessionInfo;
    private final SessionProto.SessionType sessionType;
    private final SessionMsgListener listener;

    private volatile ScheduledFuture<?> scheduledFuture;
    private volatile boolean subscribedToAttributes;
    private volatile boolean subscribedToRPC;
    private volatile boolean overwriteActivityTime;

    public SessionMetaData(SessionProto.SessionInfoProto sessionInfo, SessionProto.SessionType sessionType, SessionMsgListener listener) {
        this.sessionInfo = sessionInfo;
        this.sessionType = sessionType;
        this.listener = listener;
        this.scheduledFuture = null;
    }

    public void setScheduledFuture(ScheduledFuture<?> scheduledFuture) {
        this.scheduledFuture = scheduledFuture;
    }

    public ScheduledFuture<?> getScheduledFuture() {
        return scheduledFuture;
    }

    public boolean hasScheduledFuture() {
        return null != this.scheduledFuture;
    }
}
